$(function() {
  $('#noticeList').getList({
    "initData": {
      "num": 1,
      "size": 10
    },
    "url": site.apiUrl + "/back/announcement/searchAnnounceList", // 数据请求url
    "type": "post",
    "ajaxform": true,
    "checkname": "datachk", //选择器名称，为空不显示选择器
    "col": [ //数据列
      { "field": "title", "display": "消息标题", "width": "1.5" },
      { "field": "createTime", "display": "发布时间", "width": "1.5" },
      { "field": "userName", "display": "发布人", "width": "1.5" },
    ],
    "option": [ //操作按钮配置 // icon: view,edit,add,del
      { "icon": "edit", "tip": "编辑", "fun": "brandEdit('{{id}}')" }, // 花括号内可以对应相关字段
      { "icon": "del", "tip": "删除", "fun": "deleteBrand('{{id}}')" }
    ]
  });

  //批量删除
  $("#batchDelBtn").click(function() {
    var c = "";
    $("input[name=datachk]:checked").each(function() {
      c += $(this).val() + ',';
    });
    if (c != null && c != '') {
      deleteBrand(c);
    } else {
      ly.toast("请选择删除项");
    }

  });
});
//编辑
function brandEdit(attendanceId) {
  ly.goto("notice-list-creat.html?id=" + attendanceId + "&attendanceType=2")
}

//删除
function deleteBrand(attendanceId) {
  var url = site.apiUrl + "/back/announcement/deleteAnnouncement";
  ly.confirm("是否删除？", function() {
    request({
      url: url,
      data: { "ids": attendanceId },
      type: "post",
      ajaxform: 'true',
      callback: function(f) {
        if (f.code == "rest.success") {
          ly.toast("删除成功");
          $("#noticeList").getList.refresh(); //刷新当前分页
        }
      }
    });
  });
}